"use strict";
cc._RF.push(module, '19c73r7vS1KgqH+PAUi8YyG', 'IndexUI');
// scripts/IndexUI.js

"use strict";

var t = require;
var e = module;
var o = exports;

var _n11,
    i = void 0 && (void 0).__extends || (_n11 = function n(t, e) {
  return (_n11 = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _n11(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    s = void 0 && (void 0).__decorate || function (t, e, o, n) {
  var i,
      s = arguments.length,
      r = s < 3 ? e : null === n ? n = Object.getOwnPropertyDescriptor(e, o) : n;
  if ("object" == (typeof Reflect === "undefined" ? "undefined" : typeof Reflect) && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, n);else for (var c = t.length - 1; c >= 0; c--) {
    (i = t[c]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, o, r) : i(e, o)) || r);
  }
  return s > 3 && r && Object.defineProperty(e, o, r), r;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var r = t("Common"),
    c = t("Global"),
    a = t("UIEnum"),
    u = t("UIManager"),
    l = t("PlatfromDetailEnum"),
    d = t("SDK"),
    p = t("IndexRankItemUI"),
    h = cc._decorator,
    f = h.ccclass,
    g = h.property,
    y = function (t) {
  function e() {
    var e = null !== t && t.apply(this, arguments) || this;
    return e.ranksNode = null, e.rankContent = null, e.rankScrollView = null, e.rankItemPrefab = null, e.myRegionLabel = null, e.positionLabel = null, e.levelLabel = null, e.currentTimeLabel = null, e.difficutNode = null, e.chapterNode = null, e.tipsNode = null, e.loadingNode = null, e.positionNode = null, e.myRegionNode = null, e.wenquBtn = null, e.wenquNode = null, e.moreGameBtn = null, e.dyBtn = null, e.myRegion = "未知", e.myRegionRank = 0, e.myRegionCount = 0, e.myArea = "未知", e.myAreaRank = 0, e.myAreaCount = 0, e.myCity = "未知", e.myCityRank = 0, e.myCityCount = 0, e.ccount = 0, e.game = null, e.wenquTouchStartX = 0, e;
  }

  return i(e, t), e.prototype.onLoad = function () {
    var t = this;
    if (localStorage.getItem("Hide") != "1") t.OpenHide();
    this.chapterNode.on(cc.Node.EventType.TOUCH_END, function () {
      d["default"].isWeb() && (t.ccount++, t.ccount >= 5 && (c["default"].unlimit = !0), cc.tween(t.chapterNode).to(0.1, {
        scale: 1.1
      }).to(0.1, {
        scale: 1
      }).start());
    }, this), this.wenquBtn.on(cc.Node.EventType.TOUCH_START, function (e) {
      d["default"].isWeb() && (t.wenquTouchStartX = e.getLocation().x);
    }, this), this.wenquBtn.on(cc.Node.EventType.TOUCH_END, function (e) {
      if (d["default"].isWeb()) {
        var o = e.getLocation().x;
        o < t.wenquTouchStartX && t.wenquTouchStartX - o > 10 && (t.wenquBtn.active = !1, c["default"].hideWenqu = !0);
      }

      t.game.showItemUI(e, 6);
    }, this), this.wenquBtn.on(cc.Node.EventType.TOUCH_CANCEL, function (e) {
      if (d["default"].isWeb()) {
        var o = e.getLocation().x;
        o < t.wenquTouchStartX && t.wenquTouchStartX - o > 10 && (t.wenquBtn.active = !1, c["default"].hideWenqu = !0);
      }
    }, this);
  }, e.prototype.doWenquxing = function (t) {
    this.wenquNode.opacity = 255, this.wenquNode.scale = 0;
    var e = cc.tween;
    e(this.wenquNode).parallel(e().to(0.8, {
      scale: 3
    }), e().to(0.8, {
      opacity: 0
    })).call(function () {
      t();
    }).start();
  }, e.prototype.showChapter = function () {
    this.levelLabel.string = "lv." + (this.game.currentChapter + 1);
    var t = new Date(),
        e = t.getMonth() + 1,
        o = t.getDate();
    this.currentTimeLabel.string = "-" + e + "月" + o + "日-";
  }, e.prototype.init = function (t) {
    var e = this;
    this.game = t, this.loadingNode.active = !0, this.positionNode.active = !1, this.myRegionNode.active = !1, // d.default.sendHttpRequest(
    //     r.default.getRankUrl,
    //     {re: "true", ps: "zs"},
    //     function (t) {
    //         var o = t.rs;
    //         o.sort(function (t, e) {
    //             return t.count < e.count ? 1 : t.count > e.count ? -1 : 0;
    //         }),
    //             (e.loadingNode.active = !1),
    //             (e.positionNode.active = !0),
    //             (e.myRegionNode.active = !0),
    //             (e.myRegion = t.region),
    //             (e.myArea = t.area),
    //             (e.myCity = t.city),
    //             (e.positionLabel.string = e.myRegion);
    //         for (var n = 0; n < o.length; n++) {
    //             var i = o[n],
    //                 s = n + 1,
    //                 r = i.count,
    //                 c = i.zy;
    //             c || (c = 0);
    //             var a = i.ss;
    //             a || (a = 0);
    //             var u = i.region,
    //                 l = i.us,
    //                 d = i.zys;
    //             d || (d = []),
    //                 u == e.myRegion &&
    //                     ((e.myRegionRank = s),
    //                     (e.myRegionCount = r),
    //                     (e.myRegionLabel.string = "第" + s + "名"));
    //             var h = cc.instantiate(e.rankItemPrefab);
    //             h.getComponent(p.default).init(e, s, r, c, a, u, l, d), e.rankContent.addChild(h);
    //         }
    //         "true" == t.as && (e.ranksNode.active = !1);
    //     },
    //     function () {}
    // ),
    d["default"].isTT() && d["default"].getPlatFormDetail() == l["default"].DouYin ? (tt.createGridGamePanel ? this.moreGameBtn.active = !0 : this.moreGameBtn.active = !1, this.dyBtn.active = !0) : (this.moreGameBtn.active = !1, this.dyBtn.active = !1);
  }, e.prototype.scrollToMyCity = function () {
    for (var t = 0, e = this.rankContent.children, o = e.length, n = 0; n < e.length; n++) {
      if (e[n].getComponent(p["default"]).region == this.myRegion) {
        t = n;
        break;
      }
    }

    var i = t / o;
    this.rankScrollView.scrollToPercentVertical(1 - i - 0.02, 0.2);
  }, e.prototype.refreshRank = function () {// var t = this;
    // d.default.sendHttpRequest(
    //     r.default.getRankUrl, { re: "false" },
    //     function(e) {
    //         var o = e.rs;
    //         o.sort(function(t, e) {
    //             return t.count < e.count ? 1 : t.count > e.count ? -1 : 0;
    //         });
    //         for (var n = 0; n < o.length; n++) {
    //             var i = o[n],
    //                 s = n + 1,
    //                 r = i.count,
    //                 c = i.zy;
    //             c || (c = 0);
    //             var a = i.ss;
    //             a || (a = 0);
    //             var u = i.region,
    //                 l = i.us,
    //                 d = i.zys;
    //             d || (d = []),
    //                 u == t.myRegion &&
    //                 ((t.myRegionRank = s),
    //                     (t.myRegionCount = r),
    //                     (t.myRegionLabel.string = "第" + s + "名"));
    //             var h = t.rankContent.children[n];
    //             h && h.getComponent(p.default).init(t, s, r, c, a, u, l, d);
    //         }
    //     },
    //     function() {}
    // );
  }, e.prototype.showRankUsersUI = function (t) {
    u.UIMgr.show(a["default"].RankUsersUI, t, !1);
  }, e.prototype.showMoreGame = function () {
    d["default"].showGridAd();
  }, e.prototype.toDy = function () {
    this.game.jumpToDy();
  }, e.prototype.showTips = function (t) {
    this.tipsNode.getChildByName("label").getComponent(cc.Label).string = t, this.tipsNode.active = !0, this.tipsNode.y = 0, this.tipsNode.opacity = 255, this.tipsNode.stopAllActions(), cc.tween(this.tipsNode).to(0.5, {
      y: 100
    }).delay(1).to(0.2, {
      opacity: 0
    }).start();
  }, e.prototype.showDiffcutNode = function () {
    this.difficutNode.active = !0, this.difficutNode.x = 600, cc.tween(this.difficutNode).to(0.5, {
      x: 0
    }).delay(1.5).to(0.5, {
      x: -600
    }).start();
  }, e.prototype.startGame = function () {
    d["default"].showCustomAd();
    c["default"].complateLevel > 0 ? (this.game.currentChapter = c["default"].complateLevel + 1, this.game.currentChapter > 3 && (this.game.currentChapter = 3)) : this.game.currentChapter = 0, d["default"].isWeb() && (this.game.currentChapter = 0), this.game.initChapter(), this.ranksNode.active = !1, this.game.sendEvent("startGame");
  }, e.prototype.showHome = function () {
    this.refreshRank(), this.ranksNode.active = !0, this.game.showRankUI(null, 0);
  }, e.prototype.OpenHide = function () {
    this.HidePanel.active = true;
  }, e.prototype.YesHide = function () {
    localStorage.setItem("Hide", "1");
    this.HidePanel.active = false;
  }, e.prototype.NoHide = function () {
    qg.exitApplication({
      success: function success() {
        console.log("exitApplication success");
      },
      fail: function fail() {
        console.log("exitApplication fail");
      },
      complete: function complete() {
        console.log("exitApplication complete");
      }
    });
  }, e.prototype.start = function () {}, e.prototype.update = function () {}, s([g(cc.Node)], e.prototype, "ranksNode", void 0), s([g(cc.Node)], e.prototype, "rankContent", void 0), s([g(cc.ScrollView)], e.prototype, "rankScrollView", void 0), s([g(cc.Prefab)], e.prototype, "rankItemPrefab", void 0), s([g(cc.Label)], e.prototype, "myRegionLabel", void 0), s([g(cc.Label)], e.prototype, "positionLabel", void 0), s([g(cc.Label)], e.prototype, "levelLabel", void 0), s([g(cc.Label)], e.prototype, "currentTimeLabel", void 0), s([g(cc.Node)], e.prototype, "difficutNode", void 0), s([g(cc.Node)], e.prototype, "chapterNode", void 0), s([g(cc.Node)], e.prototype, "tipsNode", void 0), s([g(cc.Node)], e.prototype, "loadingNode", void 0), s([g(cc.Node)], e.prototype, "positionNode", void 0), s([g(cc.Node)], e.prototype, "myRegionNode", void 0), s([g(cc.Node)], e.prototype, "wenquBtn", void 0), s([g(cc.Node)], e.prototype, "wenquNode", void 0), s([g(cc.Node)], e.prototype, "moreGameBtn", void 0), s([g(cc.Node)], e.prototype, "dyBtn", void 0), s([g(cc.Node)], e.prototype, "HidePanel", void 0), s([f], e);
}(cc.Component);

o["default"] = y;

cc._RF.pop();